<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>11-递归函数求阶乘</title>
</head>
<body>
    <script>
        //递归：在函数内部自己调自己   必须使用return返回否则会出现栈溢出

        //求5的阶乘  n!=1×2×3×...×(n-1)×n
        //100 1*2*3*4.....100
        function factorial(n){
            if(n==1){
                return 1;
            }
            return n*factorial(n-1);
        }
        var x = factorial(10);
        console.log(x);


    </script>
</body>
</html>